package com.ghs.securityprojectboot.mapper;

import com.ghs.securityprojectboot.entity.DbAccount;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author shenguohui
 * @since 2024-09-03
 */
public interface DbAccountMapper extends BaseMapper<DbAccount> {
    @Select("select * from db_account where username = #{text} or email = #{text}")
    DbAccount findAccountByNameOrEmail(String text);

    @Select("select * from db_account where username = #{text} or email = #{text}")
    DbAccount findAccountUserByNameOrEmail(String text);

    @Insert("insert into db_account (email, username, password) values (#{email}, #{username}, #{password})")
    int createAccount(String username, String password, String email);

    @Update("update db_account set password = #{password} where email = #{email}")
    int resetPasswordByEmail(String password, String email);
}
